Xbasic

Helper::HtmlProcessor.ProcessHTMLResources Method

Syntax

C ProcessHTMLResources(C html [, C uri [, C flags [, C prefix [, C suffix]]]])

Arguments

html

Source to process.

uri

uri for source - used to determine the default baseURI for resources.

flags

Character

Flag
Description
e

Only process embedded bitmaps (data: protocol).

s

Include style sheets.

j

Include linked js source.

r

Recurse (includes processing of images in stylesheets).

u

Force images to have sizes (width/height).

-i]

Disable images (images are processed by default, use this flag if you only want to process stylesheets and/or javascript).

prefix

Prefix to add to replaced URIs.

suffix

Prefix to add to replaced URIs.

Description

Process html to convert ANY resources (images, optionally style sheets etc), into a standalone resource list (returned in resource array).

Discussion

The Helper::HtmlProcessor ProcessHTMLResources method captures all the resources in a page that can be resolved into the resource array of the HtmlProcessor object. The text that is returned includes the new generated resource names. The purpose to to allow a page that references external resources, like images, stylesheets and scripts in a local version that locally references all the resources that can be stored statically in a folder.

Example

dim ph as helper::HtmlProcessor
? ph.ProcessHTMLResources(< < %html%
#< img src="http://www.alphasoftware.com/images/home.png" /> 
#%html%)
= < img src="home.png" /> 
? ph.resource.size()
= 1
? ph.resource[[ 1 ]] 
...
filename = "home.png"
found = .T.
mime_type = "image/png;"
originalname = "http://www.alphasoftware.com/images/home.png"
dim blob as b = ph.resource[[ 1 ]].getcontent() 
? blob.size()
= 4572

See Also